<script setup lang="ts">
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
import api, { apiget } from "./api";
import { provide, ref } from "vue";
const user = ref();
const permmenu = ref<any[]>([]);

const feedbackset = ref({
  customer: "顾客反馈",
  customershow: 1,
  customerrequired: 1,
  method: "处理方法和结果",
  methodshow: 1,
  methodrequired: 1,
  usershow: 0,
  userrequired: 0,
});


provide("user", user);
provide("permmenu", permmenu);
provide("feedbackset", feedbackset);

function refresh() {
  apiget("/wechat/index/online")
    .then((e) => {
      if (!e) {
        uni.switchTab({
          url: "/pages/user/index",
        });
        user.value = undefined;
        return;
      }
      user.value = e;
      const to = uni.getStorageSync("to");
      uni.setStorageSync("user", user.value);
      console.log(to);
      if (to) {
        uni.navigateTo({
          url: to,
        });
      }
    })
    .catch((c) => {});
  apiget<any[]>("/wechat/index/permmenu").then((e) => {
    permmenu.value = e;
  });

  api<any[]>("/wechat/feedbackset/list").then((c) => {
    if (c[0]) {
      feedbackset.value = c[0];
    }
  });
}
provide("refresh", refresh);
onLaunch(() => {
  refresh();
});
onShow(() => {
  console.log("App Show");
});
onHide(() => {
  console.log("App Hide");
});
</script>
<style lang="scss">
@import "@/static/iconfont/iconfont.css";

.page {
  height: 100vh;
  width: 100vw;
}

.mb2 {
  margin-bottom: 12rpx;
}

.mb3 {
  margin-bottom: 18rpx;
}

.pl2 {
  padding-left: 12rpx;
}

.pl4 {
  padding-left: 24rpx;
}

.uni-popup {
  z-index: 9999 !important;
}

.flex1 {
  flex: 1 0 0%;
}

.uv-upload__deletable {
  height: 48rpx !important;
  width: 48rpx !important;

  text {
    font-size: 36rpx !important;
    line-height: 36rpx !important;
  }
}
</style>
